<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

		<title>购物车页面</title>

		<link href="/mall/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css" />
		<link href="/mall/basic/css/demo.css" rel="stylesheet" type="text/css" />
		<link href="/mall/css/cartstyle.css" rel="stylesheet" type="text/css" />
		<link href="/mall/css/optstyle.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="/mall/js/jquery.js"></script>
	</head>
	<body>

		<!--顶部导航条 -->
		<div th:replace="mall/layout/mallHeader"></div>
			<!--购物车 -->
			<div class="concent">
				<div id="cartTable">
					<div class="cart-table-th">
						<div class="wp">
							<div class="th th-chk">
								<div id="J_SelectAll1" class="select-all J_SelectAll">

								</div>
							</div>
							<div class="th th-item">
								<div class="td-inner">商品信息</div>
							</div>
							<div class="th th-price">
								<div class="td-inner">单价</div>
							</div>
							<div class="th th-amount">
								<div class="td-inner">数量</div>
							</div>
							<div class="th th-sum">
								<div class="td-inner">金额</div>
							</div>
							<div class="th th-op">
								<div class="td-inner">操作</div>
							</div>
						</div>
					</div>
					<div class="clear"></div>

					<tr class="item-list">
						<div class="bundle  bundle-last ">
							<div class="bundle-hd">
								<div class="bd-promos">
									<div class="bd-has-promo">已享优惠:<span class="bd-has-promo-content">省￥19.50</span>&nbsp;&nbsp;</div>
									<div class="act-promo">
										<a href="#" target="_blank">第二支半价，第三支免费<span class="gt">&gt;&gt;</span></a>
									</div>
									<span class="list-change theme-login">编辑</span>
								</div>
							</div>
							<div class="clear"></div>
							<div class="bundle-main">
								<ul class="item-content clearfix" th:each="goods:${cartList}">
									<li class="td td-chk">
										<div class="cart-checkbox ">
											<input class="check" id="J_CheckBox_170037950254" name="items[]" value="170037950254" type="checkbox">
											<label for="J_CheckBox_170037950254"></label>
										</div>
									</li>
									<li class="td td-item">
										<div class="item-pic">
											<a th:href="@{'/mall/goodsDetail/'+${goods.goodsid}}" target="_blank"
											   data-title="美康粉黛醉美东" class="J_MakePoint" data-point="tbcart.8.12">
												<img th:src="@{${goods.img}}" class="itempic J_ItemImg"></a>
										</div>
										<div class="item-info">
											<div class="item-basic-info">
												<a th:href="@{'/mall/goodsDetail/'+${goods.goodsid}}" th:text="${goods.goodsname}"
												   target="_blank" title="美康粉黛醉美唇膏 持久保湿滋润防水不掉色" class="item-title J_MakePoint" data-point="tbcart.8.11">美</a>
											</div>
										</div>
									</li>
									<li class="td td-info">
										<div class="item-props item-props-can">
											<span class="sku-line">颜色：12#川南玛瑙</span>
											<span class="sku-line">包装：裸装</span>
											<span tabindex="0" class="btn-edit-sku theme-login">修改</span>
											<i class="theme-login am-icon-sort-desc"></i>
										</div>
									</li>
									<li class="td td-price">
										<div class="item-price price-promo-promo">
											<div class="price-content">
												<div class="price-line">
													<em class="price-original" th:id="'price'+${goods.id}" th:text="${goods.price}">78.00</em>
												</div>
												<div class="price-line">
													<em class="J_Price price-now" tabindex="0" th:text="${goods.price}">39.00</em>
												</div>
											</div>
										</div>
									</li>
									<li class="td td-amount">
										<div class="amount-wrapper ">
											<div class="item-amount ">
												<div class="sl">
													<input class="min am-btn" th:label="${goods.id}"  th:id="'count_down_'+${goods.id}"
														   type="button" value="-" />
													<input class="text_box" name="count"
														   th:id="'goods_count_'+${goods.id}" type="text" th:value="${goods.count}" style="width:30px;" />
													<input class="add am-btn" th:label="${goods.id}" th:id="'count_up_'+${goods.id}"
														   type="button" value="+" />
												</div>
											</div>
										</div>
									</li>
									<li class="td td-sum">
										<div class="td-inner">
											<em tabindex="0" class="J_ItemSum number" th:id="'goods_total_price_'+${goods.id}"
												th:text="'￥'+${goods.totalprice}">117.00</em>
										</div>
									</li>
									<li class="td td-op">
										<div class="td-inner">
											<a title="移入收藏夹" class="btn-fav" href="#">
                  移入收藏夹</a>
											<a href="javascript:;" data-point-url="#" th:onclick="'deleteCart('+${goods.id}+')'" class="delete">
                  删除</a>
										</div>
									</li>
								</ul>
							</div>
						</div>
					</tr>
					<div class="clear"></div>

				</div>
				<div class="clear"></div>

				<div class="float-bar-wrapper">
					<div id="J_SelectAll2" class="select-all J_SelectAll">
						<div class="cart-checkbox">
							<input class="check-all check" id="J_SelectAllCbx2" name="select-all" value="true" type="checkbox">
							<label for="J_SelectAllCbx2"></label>
						</div>
						<span>全选</span>
					</div>
					<div class="operations">
						<a href="#" hidefocus="true" class="deleteAll">删除</a>
						<a href="#" hidefocus="true" class="J_BatchFav">移入收藏夹</a>
					</div>
					<div class="float-bar-right">
						<div class="amount-sum">
							<span class="txt">已选商品</span>
							<em id="J_SelectedItemsCount">0</em><span class="txt">件</span>
							<div class="arrow-box">
								<span class="selected-items-arrow"></span>
								<span class="arrow"></span>
							</div>
						</div>
						<div class="price-sum">
							<span class="txt">合计:</span>
							<strong class="price">¥<em id="J_Total" id="totalprice" th:text="${totalprice}">0.00</em></strong>
						</div>
						<div class="btn-area">
							<a href="#" id="J_Go" onclick="jiesuan()" class="submit-btn submit-btn-disabled"
							   aria-label="请注意如果没有选择宝贝，将无法结算">
								<span>结&nbsp;算</span></a>
						</div>
					</div>

				</div>

				<div th:replace="mall/layout/mallFooter"></div>

			</div>

			<!--操作页面-->

			<div class="theme-popover-mask"></div>

			<div class="theme-popover">
				<div class="theme-span"></div>
				<div class="theme-poptit h-title">
					<a href="javascript:;" title="关闭" class="close">×</a>
				</div>
				<div class="theme-popbod dform">
					<form class="theme-signin" name="loginform" action="" method="post">

						<div class="theme-signin-left">

							<li class="theme-options">
								<div class="cart-title">颜色：</div>
								<ul>
									<li class="sku-line selected">12#川南玛瑙<i></i></li>
									<li class="sku-line">10#蜜橘色+17#樱花粉<i></i></li>
								</ul>
							</li>
							<li class="theme-options">
								<div class="cart-title">包装：</div>
								<ul>
									<li class="sku-line selected">包装：裸装<i></i></li>
									<li class="sku-line">两支手袋装（送彩带）<i></i></li>
								</ul>
							</li>
							<div class="theme-options">
								<div class="cart-title number">数量</div>
								<dd>
									<input class="min am-btn am-btn-default" name="" type="button" value="-" />
									<input class="text_box" name="" type="text" value="1" style="width:30px;" />
									<input class="add am-btn am-btn-default" name="" type="button" value="+" />
									<span  class="tb-hidden">库存<span class="stock">1000</span>件</span>
								</dd>

							</div>
							<div class="clear"></div>
							<div class="btn-op">
								<div class="btn am-btn am-btn-warning">确认</div>
								<div class="btn close am-btn am-btn-warning">取消</div>
							</div>

						</div>
						<div class="theme-signin-right">
							<div class="img-info">
								<img src="/mall/images/kouhong.jpg_80x80.jpg" />
							</div>
							<div class="text-info">
								<span class="J_Price price-now">¥39.00</span>
								<span id="Stock" class="tb-hidden">库存<span class="stock">1000</span>件</span>
							</div>
						</div>

					</form>
				</div>
			</div>
		<!--引导 -->
		<div th:replace="mall/layout/wapNav"></div>
	</body>
	<script type="text/javascript">
        function goods_count_adjust(cart_id,count){
            jQuery.post("/person/mall/goods_count_adjust",{"cart_id":cart_id,"count":count},function(data){
                if(data.code==0){
                    jQuery("#goods_count_"+cart_id).val(count);
                    jQuery("#goods_count_"+cart_id).attr("goods_count",count)
                    jQuery("#goods_total_price_"+cart_id).html("¥"+data.goodsprice);
                    jQuery("#totalprice").html(data.totalprice);
                }
                if(data.code=="200"){
                    alert("库存不足，请重新选择数量！");
                    jQuery("#goods_count_"+cart_id).val(jQuery("#goods_count_"+cart_id).attr("goods_count"));
                }
                if(data.code=="300"){
                    alert("团购库存不足，请重新选择数量！");
                    jQuery("#goods_count_"+cart_id).val(jQuery("#goods_count_"+cart_id).attr("goods_count"));
                }
            },"json");
        }
        jQuery("input[id^=count_down]").click(function(){
            var cart_id=jQuery(this).attr("label");
            var count=jQuery("#goods_count_"+cart_id).val();
            if(count>1){
                count--;
                goods_count_adjust(cart_id,count)
            }
        });
        jQuery("input[id^=count_up]").click(function(){
            var cart_id=jQuery(this).attr("label");
            console.log('cart_id:'+cart_id);
            var count=jQuery("#goods_count_"+cart_id).val();
            if(count>0){
                count++;
                goods_count_adjust(cart_id,count);
            }
        });

        function addCart(goodsid){
            console.log(goodsid);
            var count=1;
            $.ajax({
                type: "post",
                url: '/person/mall/addCart',
                data: {
                    goodsid:goodsid,
                    count:count},
                dataType: "json",
                success:function(data) {
                    if(data.code==0){
                        window.location.href = "/person/mall/likBuy/"+goodsid;
                    }else if(data.success=='login'){
                        window.location.href = "/mall/login"
                    }
                }
            });
        }
        function deleteCart(goodsid){
            $.ajax({
                type: "post",
                url: '/person/mall/deleteCart',
                data: {
                    goodsid:goodsid
                },
                dataType: "json",
                success:function(data) {
                    if(data.code==0){
                        layer.msg("删除购物车成功!");
                    }else if(data.success=='login'){
                        window.location.href = "/mall/login"
                    }
                }
            });
        }
        function jiesuan(){
            window.location.href = "/person/mall/likBuy1";
        }
        function addRePly(){
            var content=$("#say_some").val();
            var goodsid=$("#goodsid").val();
            $.ajax({
                type: "post",
                url: '/person/mall/addRePly',
                data: {content:content,goodsid:goodsid},
                dataType: "json",
                success:function(data) {
                    if(data.success){
                        layer.msg("评论成功!",{icon:2});

                    }else{
                        layer.msg("评论失败!",{icon:2});
                    }
                }
            });
        }
	</script>

</html>